package com.dhn.controller;


import com.dhn.entity.Room;
import com.dhn.service.RoomService;
import com.dhn.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class RoomController {
       @Autowired
        private RoomService roomService;
       @RequestMapping("getRooms")
       @ResponseBody
       public Object getRooms(Room room){
           int abc = roomService.getTotal(room);
           room.setPage((room.getPage()-1)*room.getLimit());
           List<Room> efg = roomService.getRooms(room);
           return Result.toClient("0","",abc,efg);
       }

}
